/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.me.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Jayasundara
 */
@Entity
@Table(name = "user", catalog = "postgres", schema = "public")
@NamedQueries({@NamedQuery(name = "User.findAll", query = "SELECT u FROM User u"), @NamedQuery(name = "User.findById", query = "SELECT u FROM User u WHERE u.id = :id"), @NamedQuery(name = "User.findByEmail", query = "SELECT u FROM User u WHERE u.email = :email"), @NamedQuery(name = "User.findByPassword", query = "SELECT u FROM User u WHERE u.password = :password"), @NamedQuery(name = "User.findByFirstName", query = "SELECT u FROM User u WHERE u.firstName = :firstName"), @NamedQuery(name = "User.findByLastName", query = "SELECT u FROM User u WHERE u.lastName = :lastName")})
public class User implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Integer id;
    @Column(name = "email", length = 25)
    private String email;
    @Column(name = "password", length = 15)
    private String password;
    @Column(name = "first_name", length = 15)
    private String firstName;
    @Column(name = "last_name", length = 15)
    private String lastName;
    @OneToMany(mappedBy = "leadUser")
    private List<Project> projectCollection;
    @OneToMany(mappedBy = "assigneeId")
    private List<Task> taskCollection;
    @OneToMany(mappedBy = "recorderId")
    private List<Task> taskCollection1;
    @OneToMany(mappedBy = "reporterId")
    private List<Task> taskCollection2;
    @OneToMany(mappedBy = "componentLead")
    private List<Component> componentCollection;
    @JoinColumn(name = "prefix_id", referencedColumnName = "id")
    @ManyToOne
    private NamePrefix prefixId;
    @JoinColumn(name = "role_id", referencedColumnName = "id")
    @ManyToOne
    private NamePrefix roleId;

    public User() {
    }

    public User(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public List<Project> getProjectCollection() {
        return projectCollection;
    }

    public void setProjectCollection(List<Project> projectCollection) {
        this.projectCollection = projectCollection;
    }

    public List<Task> getTaskCollection() {
        return taskCollection;
    }

    public void setTaskCollection(List<Task> taskCollection) {
        this.taskCollection = taskCollection;
    }

    public List<Task> getTaskCollection1() {
        return taskCollection1;
    }

    public void setTaskCollection1(List<Task> taskCollection1) {
        this.taskCollection1 = taskCollection1;
    }

    public List<Task> getTaskCollection2() {
        return taskCollection2;
    }

    public void setTaskCollection2(List<Task> taskCollection2) {
        this.taskCollection2 = taskCollection2;
    }

    public List<Component> getComponentCollection() {
        return componentCollection;
    }

    public void setComponentCollection(List<Component> componentCollection) {
        this.componentCollection = componentCollection;
    }

    public NamePrefix getPrefixId() {
        return prefixId;
    }

    public void setPrefixId(NamePrefix prefixId) {
        this.prefixId = prefixId;
    }

    public NamePrefix getRoleId() {
        return roleId;
    }

    public void setRoleId(NamePrefix roleId) {
        this.roleId = roleId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof User)) {
            return false;
        }
        User other = (User) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.me.entity.User[id=" + id + "]";
    }

}
